package com.fr.report.core.barcode.line.code39;

import com.fr.report.core.barcode.Module;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class ModuleFactory
{
  public static final Module START_STOP = new Module(new int[] { 1, 2, 1, 1, 2, 1, 2, 1, 1 });
  private static final List KEYS = new ArrayList();
  private static final Map SET = new HashMap();
  private static final Map EXT_CHARS = new HashMap();
  private static final List ESCAPE_CHARS = new ArrayList();

  private static void initBaseSet()
  {
    KEYS.add("0");
    SET.put("0", new Module(new int[] { 1, 1, 1, 2, 2, 1, 2, 1, 1 }));
    KEYS.add("1");
    SET.put("1", new Module(new int[] { 2, 1, 1, 2, 1, 1, 1, 1, 2 }));
    KEYS.add("2");
    SET.put("2", new Module(new int[] { 1, 1, 2, 2, 1, 1, 1, 1, 2 }));
    KEYS.add("3");
    SET.put("3", new Module(new int[] { 2, 1, 2, 2, 1, 1, 1, 1, 1 }));
    KEYS.add("4");
    SET.put("4", new Module(new int[] { 1, 1, 1, 2, 2, 1, 1, 1, 2 }));
    KEYS.add("5");
    SET.put("5", new Module(new int[] { 2, 1, 1, 2, 2, 1, 1, 1, 1 }));
    KEYS.add("6");
    SET.put("6", new Module(new int[] { 1, 1, 2, 2, 2, 1, 1, 1, 1 }));
    KEYS.add("7");
    SET.put("7", new Module(new int[] { 1, 1, 1, 2, 1, 1, 2, 1, 2 }));
    KEYS.add("8");
    SET.put("8", new Module(new int[] { 2, 1, 1, 2, 1, 1, 2, 1, 1 }));
    KEYS.add("9");
    SET.put("9", new Module(new int[] { 1, 1, 2, 2, 1, 1, 2, 1, 1 }));
    KEYS.add("A");
    SET.put("A", new Module(new int[] { 2, 1, 1, 1, 1, 2, 1, 1, 2 }));
    KEYS.add("B");
    SET.put("B", new Module(new int[] { 1, 1, 2, 1, 1, 2, 1, 1, 2 }));
    KEYS.add("C");
    SET.put("C", new Module(new int[] { 2, 1, 2, 1, 1, 2, 1, 1, 1 }));
    KEYS.add("D");
    SET.put("D", new Module(new int[] { 1, 1, 1, 1, 2, 2, 1, 1, 2 }));
    KEYS.add("E");
    SET.put("E", new Module(new int[] { 2, 1, 1, 1, 2, 2, 1, 1, 1 }));
    KEYS.add("F");
    SET.put("F", new Module(new int[] { 1, 1, 2, 1, 2, 2, 1, 1, 1 }));
    KEYS.add("G");
    SET.put("G", new Module(new int[] { 1, 1, 1, 1, 1, 2, 2, 1, 2 }));
    KEYS.add("H");
    SET.put("H", new Module(new int[] { 2, 1, 1, 1, 1, 2, 2, 1, 1 }));
    KEYS.add("I");
    SET.put("I", new Module(new int[] { 1, 1, 2, 1, 1, 2, 2, 1, 1 }));
    KEYS.add("J");
    SET.put("J", new Module(new int[] { 1, 1, 1, 1, 2, 2, 2, 1, 1 }));
    KEYS.add("K");
    SET.put("K", new Module(new int[] { 2, 1, 1, 1, 1, 1, 1, 2, 2 }));
    KEYS.add("L");
    SET.put("L", new Module(new int[] { 1, 1, 2, 1, 1, 1, 1, 2, 2 }));
    KEYS.add("M");
    SET.put("M", new Module(new int[] { 2, 1, 2, 1, 1, 1, 1, 2, 1 }));
    KEYS.add("N");
    SET.put("N", new Module(new int[] { 1, 1, 1, 1, 2, 1, 1, 2, 2 }));
    KEYS.add("O");
    SET.put("O", new Module(new int[] { 2, 1, 1, 1, 2, 1, 1, 2, 1 }));
    KEYS.add("P");
    SET.put("P", new Module(new int[] { 1, 1, 2, 1, 2, 1, 1, 2, 1 }));
    KEYS.add("Q");
    SET.put("Q", new Module(new int[] { 1, 1, 1, 1, 1, 1, 2, 2, 2 }));
    KEYS.add("R");
    SET.put("R", new Module(new int[] { 2, 1, 1, 1, 1, 1, 2, 2, 1 }));
    KEYS.add("S");
    SET.put("S", new Module(new int[] { 1, 1, 2, 1, 1, 1, 2, 2, 1 }));
    KEYS.add("T");
    SET.put("T", new Module(new int[] { 1, 1, 1, 1, 2, 1, 2, 2, 1 }));
    KEYS.add("U");
    SET.put("U", new Module(new int[] { 2, 2, 1, 1, 1, 1, 1, 1, 2 }));
    KEYS.add("V");
    SET.put("V", new Module(new int[] { 1, 2, 2, 1, 1, 1, 1, 1, 2 }));
    KEYS.add("W");
    SET.put("W", new Module(new int[] { 2, 2, 2, 1, 1, 1, 1, 1, 1 }));
    KEYS.add("X");
    SET.put("X", new Module(new int[] { 1, 2, 1, 1, 2, 1, 1, 1, 2 }));
    KEYS.add("Y");
    SET.put("Y", new Module(new int[] { 2, 2, 1, 1, 2, 1, 1, 1, 1 }));
    KEYS.add("Z");
    SET.put("Z", new Module(new int[] { 1, 2, 2, 1, 2, 1, 1, 1, 1 }));
    KEYS.add("-");
    SET.put("-", new Module(new int[] { 1, 2, 1, 1, 1, 1, 2, 1, 2 }));
    KEYS.add(".");
    SET.put(".", new Module(new int[] { 2, 2, 1, 1, 1, 1, 2, 1, 1 }));
    KEYS.add(" ");
    SET.put(" ", new Module(new int[] { 1, 2, 2, 1, 1, 1, 2, 1, 1 }));
    KEYS.add("$");
    SET.put("$", new Module(new int[] { 1, 2, 1, 2, 1, 2, 1, 1, 1 }));
    KEYS.add("/");
    SET.put("/", new Module(new int[] { 1, 2, 1, 2, 1, 1, 1, 2, 1 }));
    KEYS.add("+");
    SET.put("+", new Module(new int[] { 1, 2, 1, 1, 1, 2, 1, 2, 1 }));
    KEYS.add("%");
    SET.put("%", new Module(new int[] { 1, 1, 1, 2, 1, 2, 1, 2, 1 }));
  }

  private static void initExtendedSet()
  {
    ESCAPE_CHARS.add("$");
    ESCAPE_CHARS.add("/");
    ESCAPE_CHARS.add("+");
    ESCAPE_CHARS.add("%");
    EXT_CHARS.put(new Character('), "%U");
    EXT_CHARS.put(new Character('\1'), "$A");
    EXT_CHARS.put(new Character('\2'), "$B");
    EXT_CHARS.put(new Character('\3'), "$C");
    EXT_CHARS.put(new Character('\4'), "$D");
    EXT_CHARS.put(new Character('\5'), "$E");
    EXT_CHARS.put(new Character('\6'), "$F");
    EXT_CHARS.put(new Character('\7'), "$G");
    EXT_CHARS.put(new Character('\b'), "$H");
    EXT_CHARS.put(new Character('\t'), "$I");
    EXT_CHARS.put(new Character('\n'), "$J");
    EXT_CHARS.put(new Character('\11'), "$K");
    EXT_CHARS.put(new Character('\f'), "$L");
    EXT_CHARS.put(new Character('\r'), "$M");
    EXT_CHARS.put(new Character('\14'), "$N");
    EXT_CHARS.put(new Character('\15'), "$O");
    EXT_CHARS.put(new Character('\16'), "$P");
    EXT_CHARS.put(new Character('\17'), "$Q");
    EXT_CHARS.put(new Character('\18'), "$R");
    EXT_CHARS.put(new Character('\19'), "$S");
    EXT_CHARS.put(new Character('\20'), "$T");
    EXT_CHARS.put(new Character('\21'), "$U");
    EXT_CHARS.put(new Character('\22'), "$V");
    EXT_CHARS.put(new Character('\23'), "$W");
    EXT_CHARS.put(new Character('\24'), "$X");
    EXT_CHARS.put(new Character('\25'), "$Y");
    EXT_CHARS.put(new Character('\26'), "$Z");
    EXT_CHARS.put(new Character('\27'), "%A");
    EXT_CHARS.put(new Character('\28'), "%B");
    EXT_CHARS.put(new Character('\29'), "%C");
    EXT_CHARS.put(new Character('\30'), "%D");
    EXT_CHARS.put(new Character('\31'), "%E");
    EXT_CHARS.put(new Character(''), "%T");
    EXT_CHARS.put(new Character('!'), "/A");
    EXT_CHARS.put(new Character('"'), "/B");
    EXT_CHARS.put(new Character('#'), "/C");
    EXT_CHARS.put(new Character('$'), "/D");
    EXT_CHARS.put(new Character('%'), "/E");
    EXT_CHARS.put(new Character('&'), "/F");
    EXT_CHARS.put(new Character('\''), "/G");
    EXT_CHARS.put(new Character('('), "/H");
    EXT_CHARS.put(new Character(')'), "/I");
    EXT_CHARS.put(new Character('*'), "/J");
    EXT_CHARS.put(new Character('+'), "/K");
    EXT_CHARS.put(new Character(','), "/L");
    EXT_CHARS.put(new Character('/'), "/O");
    EXT_CHARS.put(new Character(':'), "/Z");
    EXT_CHARS.put(new Character(';'), "%F");
    EXT_CHARS.put(new Character('?'), "%G");
    EXT_CHARS.put(new Character('='), "%H");
    EXT_CHARS.put(new Character('>'), "%I");
    EXT_CHARS.put(new Character('?'), "%J");
    EXT_CHARS.put(new Character('@'), "%V");
    EXT_CHARS.put(new Character('['), "%K");
    EXT_CHARS.put(new Character('\\'), "%L");
    EXT_CHARS.put(new Character(']'), "%M");
    EXT_CHARS.put(new Character('^'), "%N");
    EXT_CHARS.put(new Character('_'), "%O");
    EXT_CHARS.put(new Character('`'), "%W");
    EXT_CHARS.put(new Character('{'), "%P");
    EXT_CHARS.put(new Character('|'), "%Q");
    EXT_CHARS.put(new Character('}'), "%R");
    EXT_CHARS.put(new Character('~'), "%S");
    EXT_CHARS.put(new Character('a'), "+A");
    EXT_CHARS.put(new Character('b'), "+B");
    EXT_CHARS.put(new Character('c'), "+C");
    EXT_CHARS.put(new Character('d'), "+D");
    EXT_CHARS.put(new Character('e'), "+E");
    EXT_CHARS.put(new Character('f'), "+F");
    EXT_CHARS.put(new Character('g'), "+G");
    EXT_CHARS.put(new Character('h'), "+H");
    EXT_CHARS.put(new Character('i'), "+I");
    EXT_CHARS.put(new Character('j'), "+J");
    EXT_CHARS.put(new Character('k'), "+K");
    EXT_CHARS.put(new Character('l'), "+L");
    EXT_CHARS.put(new Character('m'), "+M");
    EXT_CHARS.put(new Character('n'), "+N");
    EXT_CHARS.put(new Character('o'), "+O");
    EXT_CHARS.put(new Character('p'), "+P");
    EXT_CHARS.put(new Character('q'), "+Q");
    EXT_CHARS.put(new Character('r'), "+R");
    EXT_CHARS.put(new Character('s'), "+S");
    EXT_CHARS.put(new Character('t'), "+T");
    EXT_CHARS.put(new Character('u'), "+U");
    EXT_CHARS.put(new Character('v'), "+V");
    EXT_CHARS.put(new Character('w'), "+W");
    EXT_CHARS.put(new Character('x'), "+X");
    EXT_CHARS.put(new Character('y'), "+Y");
    EXT_CHARS.put(new Character('z'), "+Z");
  }

  public static Module getModule(String paramString)
  {
    Module localModule = null;
    localModule = (Module)SET.get(paramString);
    localModule.setSymbol(paramString);
    return localModule;
  }

  public static int getIndex(String paramString)
  {
    return KEYS.indexOf(paramString);
  }

  public static boolean hasModule(String paramString, boolean paramBoolean)
  {
    if ((paramBoolean) && (ESCAPE_CHARS.contains(paramString)))
      return false;
    return (getIndex(paramString) != -1);
  }

  public static Module getModuleForIndex(int paramInt)
  {
    return getModule((String)KEYS.get(paramInt));
  }

  public static String getExtendedCharacter(char paramChar)
  {
    return ((String)EXT_CHARS.get(new Character(paramChar)));
  }

  static
  {
    initBaseSet();
    initExtendedSet();
  }
}